package com.xiashitech.agent.instrumentation.redis.jedis;

import com.xiashitech.agent.instrumentation.redis.RedisData;
import com.xiashitech.agent.instrumentation.redis.XSJedisAttributesExtractor;
import io.opentelemetry.javaagent.shaded.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.javaagent.shaded.io.opentelemetry.api.GlobalOpenTelemetry;

public class XSJedisSingletons {
    private XSJedisSingletons() {}
    private static final String INSTRUMENTATION_NAME = "com.xiashitech.jedis";
    private static final String SPAN_NAME = "xs.jedis";
    private static final Instrumenter<RedisData, RedisData> INSTRUMENTER;
    public static Instrumenter<RedisData, RedisData> instrumenter() {
        return INSTRUMENTER;
    }

    static {
        INSTRUMENTER =
                Instrumenter.<RedisData, RedisData>builder(
                                GlobalOpenTelemetry.get(),
                                INSTRUMENTATION_NAME,
                                request -> SPAN_NAME
                        ).addAttributesExtractor(new XSJedisAttributesExtractor())
                        .buildInstrumenter();
    }
}
